#ifndef _LOGIN_H
#define _LOGIN_H

#include <QDialog>
#include <QMouseEvent>
#include <QPoint>
#include <QTimer>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QJsonObject>
#include <QJsonParseError>
#include <QCryptographicHash>
#include <QStandardPaths>
#include <QPainter>
#include <QtMath>
#include "log.h"
#include "home.h"
#include "httpcommon.h"
#include "ui_login.h"
#include "globaldata.h"

class Login : public QDialog {
	Q_OBJECT
public:
	Login(QWidget *parent = 0);
	~Login();

protected:
	virtual void mousePressEvent(QMouseEvent *event);
	virtual void mouseMoveEvent(QMouseEvent *event);
	virtual void keyPressEvent(QKeyEvent *event);
	bool eventFilter(QObject* obj, QEvent* e);
	void paintEvent(QPaintEvent *event);

	private Q_SLOTS:
	void on_pbLogin_clicked();
	void on_pbMin_clicked();
	void on_pbClose_clicked();
	void on_pbCfg_clicked();
	void on_pbSure_clicked();

	void clearTimerMessage();

private:
	void initDb();
	void loadConfigData();
	void initWidget();
	void updateConfig(QString key, QString value);
	void showMessage(QString);
	void setPageIndex(int index);

private:
	Ui::Login ui;
	QSqlDatabase m_database;
	QSqlQuery m_sqlQuery;
	QTimer m_msgTimer;

	QPoint m_windowPos;
	QPoint m_mousePos;
	QPoint m_dPos;

	Home *m_home;
};

#endif//_LOGIN_H
